home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Listing 3: Directory Functions
-
-
- /*-----------------------------------------------------
- Directory search macros and data structures
-
- DOSFileData MS-DOS file data structure
- FIND_FIRST MS-DOS function 0x4E -- find first file
- FIND_NEXT MS-DOS function 0x4F -- find next file
- -------------------------------------------------------
-
- /* make sure the struct is packed on byte boundary */
- #if defined(_MSC_VER) || defined(_QC) ||
- defined(__WATCOMC__)
- #pragma pack(1)
- #elif defined(__ZTC__)
- #pragma align 1
- #elif defined(__TURBOC__)
- #pragma option -a-
- #endif
-
- /* use this struct instead of compiler-defined file
- struct */
- typedef struct
- {
- char reserved[21];
- char attrib;
- unsigned time;
- unsigned date;
- long size;
- char name[13];
- }
- DOSFileData;
-
- /* set structure alignment to default */
- #if defined (_MSC_VER) || defined(_QC) ||
- defined(__WATCOMC__)
- #pragma pack()
- #elif defined(__ZTC__)
- #pragma align
- #elif defined(__TURBOC__)
- #pragma option -a.
- #endif
-
- /* include proper header files and create macros */
- #if defined(_MSC_VER) || defined(_QC) ||
- defined(__WATCOMC__)
- #include "direct.h"
-
- #define FIND_FIRST(spec, attr, buf) \
- _dos_findfirst(spec, attr, (struct find_t *)buf)
- #define FIND_NEXT(buf) _dos_findnext((struct find_t
- *)buf)
- #elif defined(__TURBOC__)
- #include "dir.h"
-
- #define FIND_FIRST(spec, attr, buf) \
- findfirst(spec, (struct ffblk *)buf, attr)
- #define FIND_NEXT(buf) findnext((struct ffblk
- *)buf)
- #elif defined(__ZTC__)
- #include "dos.h"
-
- #define FIND_FIRST(spec, attr, buf) \
- dos_findfirst(spec, attr, (struct DOS_FIND *)buf)
- #define FIND_NEXT(buf) dos_findnext((struct
- DOS_FIND *)buf)
- #endif
-
-
-